﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MangoMes.Write.API.Applications.Login;
using MediatR;

namespace ManagoMes.Read.API.Applications.ProductionScheduling
{
    public class SchedulingDisplayBackhandler : IRequestHandler<SchedulingDisplayBackCommond, ResultsDTO<givebirth>>
    {

        private readonly IBateRepository<givebirth> _givebirth;
        private readonly Logincommonality _Logincommonality;

        public SchedulingDisplayBackhandler(IBateRepository<givebirth> givebirth, Logincommonality logincommonality)
        {
            _givebirth = givebirth;
            _Logincommonality = logincommonality;
        }

        public async Task<ResultsDTO<givebirth>> Handle(SchedulingDisplayBackCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list = new ResultsDTO<givebirth>() { Code = 0 };
                var str = "select * from givebirth WHERE Productionid=" + request.Productionid + "";
                var Empty = new givebirth();
                DapperHelper dapperHelper = new DapperHelper();
                list.Data = _givebirth.GetAll(str, Empty, dapperHelper.MangoMesRead).ToList();
                var OperatorName = "123";
                var OperatorTime = DateTime.Now.ToString();
                var PerformOperation = "生产任务反填";
                _Logincommonality.Loginaddget(OperatorName, OperatorTime, PerformOperation);
                return list;
            }
            catch (Exception)
            {

                throw;
            }
           




        }
    }
}
